package com.example.hello.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.example.hello.entity.WorkOrder;

@Mapper
public interface WorkOrderMapper {
    @Insert("INSERT INTO work_orders (device_id, description, assigned_to, priority) " +
            "VALUES (#{deviceId}, #{description}, #{assignedTo}, #{priority})")
    @Options(useGeneratedKeys = true, keyProperty = "workOrderId")
    int insert(WorkOrder workOrder);

    @Update("UPDATE work_orders SET status = #{status} WHERE work_order_id = #{workOrderId}")
    int updateStatus(@Param("workOrderId") Integer workOrderId, @Param("status") String status);

    @Select("SELECT * FROM work_orders WHERE status = #{status}")
    List<WorkOrder> findByStatus(String status);

    @Select("SELECT * FROM work_orders WHERE work_order_id = #{workOrderId}")
    WorkOrder findById(Integer workOrderId);
} 